<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>编辑部门</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layui-edit-form" id="edit-div">
    <input type="hidden" id="id" name="id" />
    
    <div class="layui-row">
        <div class="layui-col-sm6">
            <label class="layui-form-label"><span class="layui-badge-required"></span>部门名称</label>
            <div class="layui-input-block">
                <input type="text" name="deptName" id="deptName" lay-reqtext="部门名称不能为空" placeholder="请输入部门名称" 
                	lay-verify="required"  value="" class="layui-input" maxlength="50" />
            </div>
        </div>
        <div class="layui-col-sm6">
            <label class="layui-form-label">部门编码</label>
            <div class="layui-input-block">
                <input type="text" name="deptCode" id="deptCode" value="" class="layui-input"/>
            </div>
        </div>
    </div>
    
    <div class="layui-row">
        <div class="layui-col-sm6">
            <label class="layui-form-label">负责人</label>
            <div class="layui-input-block">
                <input type="text" name="leaderName" id="leaderName" value="" class="layui-input" maxlength="50" />
            </div>
        </div>
        <div class="layui-col-sm6">
            <label class="layui-form-label">联系电话</label>
            <div class="layui-input-block">
                <input type="text" name="linkPhone" id="linkPhone" value="" class="layui-input" maxlength="50" />
            </div>
        </div>
    </div>
    
    <div class="layui-row">
        <div class="layui-col-sm6">
            <label class="layui-form-label">联系邮箱</label>
            <div class="layui-input-block">
                <input type="text" name="linkEmail" id="linkEmail" value="" class="layui-input" maxlength="50" />
            </div>
        </div>
    </div>
    
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;"></fieldset>
    
    <div class="layui-form-item layui-form-text" style="margin-top:6px;">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea name="remark" id="remark" class="layui-textarea"  maxlength="300"></textarea>
        </div>
    </div>
    
    <div class="layui-row layui-submit-box">
        <div class="layui-input-block layui-submit-button">
          <button type="submit" class="layui-btn" lay-submit="" lay-filter="saveBtn">保存</button>
        </div>
    </div>
</div>

<script src="../../lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<script src="../../js/app.js" charset="utf-8"></script>
<script src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form;
        var layer = layui.layer;
        var $ = layui.$;

        var deptBean = global_getAndRemoveLocalStorage("dept-list#object") || {};
        var deptId = deptBean.id;

        if(deptId){
            $('#id').val(deptBean.id);

            $('#deptName').val(deptBean.dept_name);
            $('#deptCode').val(deptBean.dept_code);

            $('#leaderName').val(deptBean.leader_name);
            $('#linkPhone').val(deptBean.link_phone);
            $('#linkEmail').val(deptBean.link_email);

            $('#remark').val(deptBean.remark);

            form.render();
        }else{
            $('#id').val(0);
        }

        //保存修改
        form.on('submit(saveBtn)', function(data) {
            $.ajax({
                url : "/hrDept/saveDeptInfo",
                type : "POST",
                contentType : "application/json; charset=utf-8",
                data : JSON.stringify(data.field),
                success : function(data) {
                   if(data.result == 'ok'){
                	   var iframeIndex = parent.layer.getFrameIndex(window.name);
                       parent.layer.close(iframeIndex);
                       parent.layui.table.reload('currentTableId');
                       parent.alert_msg('保存成功！');
                       
                   }else{
                       alert_msg('操作未成功，请稍后重试或联系管理员！',2,0);
                   }
                }
            });
            return false;
        });
     
      
        
    });
</script>
</body>
</html>
